import network
import os
import time

def sta_test():
    sta = network.WLAN(0)
    # 连接用户指定的WiFi
    sta.connect("Ruijie-611_5G", "88888888")
    print("正在连接WiFi...")
    # 等待分配到IP
    while sta.ifconfig()[0] == '0.0.0.0':
        time.sleep(1)
    print("连接成功，IP配置:", sta.ifconfig())
    print("是否连接:", sta.isconnected())

sta_test()

